package com.ruoyi.comment.service.impl;

import com.ruoyi.comment.domain.Comment;
import com.ruoyi.comment.mapper.CommentMapper;
import com.ruoyi.comment.service.ICommentService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论信息Service业务层处理
 *
 * @author lin
 * @date 2024-11-22
 */
@Service
public class CommentServiceImpl implements ICommentService
{
    @Autowired(required = false)
    private CommentMapper commentMapper;

    /**
     * 查询评论信息
     *
     * @param id 评论信息主键
     * @return 评论信息
     */
    @Override
    public Comment selectCommentById(Long id)
    {
        return commentMapper.selectCommentById(id);
    }

    /**
     * 查询评论信息列表
     *
     * @param comment 评论信息
     * @return 评论信息
     */
    @Override
    public List<Comment> selectCommentList(Comment comment)
    {
        return commentMapper.selectCommentList(comment);
    }

    @Override
    public List<Comment> selectCommentListByPID(Long PID) {
        return commentMapper.selectCommentListByPID(PID);
    }

    /**
     * 新增评论信息
     *
     * @param comment 评论信息
     * @return 结果
     */
    @Override
    public int insertComment(Comment comment)
    {
        comment.setCreateTime(DateUtils.getNowDate());
        return commentMapper.insertComment(comment);
    }

    /**
     * 修改评论信息
     *
     * @param comment 评论信息
     * @return 结果
     */
    @Override
    public int updateComment(Comment comment)
    {
        return commentMapper.updateComment(comment);
    }

    /**
     * 批量删除评论信息
     *
     * @param ids 需要删除的评论信息主键
     * @return 结果
     */
    @Override
    public int deleteCommentByIds(Long[] ids)
    {
        return commentMapper.deleteCommentByIds(ids);
    }

    /**
     * 删除评论信息信息
     *
     * @param id 评论信息主键
     * @return 结果
     */
    @Override
    public int deleteCommentById(Long id)
    {
        return commentMapper.deleteCommentById(id);
    }

    @Override
    public Long getCommentListTotal(Long productId) {
        return null;
    }
}
